// 移动端导航 JS 处理

let openClass = 'isOpen'; // 打开状态类名

const openBtn = document.querySelector('.open'); // 打开按钮
const navList = document.querySelector('.mobile-nav-list'); // 导航列表

// 绑定打开按钮点击事件
openBtn.addEventListener('click', () => {
  const openBtnClassList = openBtn.classList;
  if (openBtnClassList.contains(openClass)) {
    openBtn.classList.remove(openClass);
    navList.style.height = '0';
    document.body.style.overflow = 'auto';
  } else {
    openBtn.classList.add(openClass);
    navList.style.height = 'calc(100vh - 70px)';
    document.body.style.overflow = 'hidden';
  }
});

window.addEventListener('resize', () => {
  if (window.innerWidth > 1000) {
    document.body.style.overflow = 'auto';
  }
});
